#include "PacketObjectSpawn.h"
#include <iostream>
#include "Buffer.h"
PacketObjectSpawn::PacketObjectSpawn(void)
	:
	Packet(PACKET_TYPE::OBJECT_SPAWN),
	m_objectType(OBJECT_TYPE::BASE),
	m_position(),
	m_ownerID(0),
	m_sourceID(0),
	m_targetID(0)
{

}
PacketObjectSpawn::PacketObjectSpawn(Buffer& buffer)
{
	Read(buffer);
}
PacketObjectSpawn::PacketObjectSpawn(long long objectID, OBJECT_TYPE type, Position& pos, long long ownerID, long long sourceID, long long targetID)
	:
	Packet(PACKET_TYPE::OBJECT_SPAWN),
	m_objectType(type),
	m_objectID(objectID),
	m_position(pos),
	m_ownerID(ownerID),
	m_sourceID(sourceID),
	m_targetID(targetID)
{

}
PacketObjectSpawn::~PacketObjectSpawn(void)
{

}

int PacketObjectSpawn::Write(void* buffer)
{
	int len = sizeof(*this) - 4;
	memcpy(buffer, (char*)this + 4, len); 
	return len;
}
void PacketObjectSpawn::Read(Buffer& buffer)
{
	buffer.Read(reinterpret_cast<char*>(this) + 4, sizeof(PacketObjectSpawn) - 4);
}
OBJECT_TYPE PacketObjectSpawn::GetObjectType(void) const
{
	return m_objectType;
}
Position& PacketObjectSpawn::GetPosition(void) 
{
	return m_position;
}
long long PacketObjectSpawn::GetOwnerID(void) const
{
	return m_ownerID;
}
long long PacketObjectSpawn::GetObjectID(void) const
{
	return m_objectID;
}